<?php
// +--------------------+------------------+------+-----+---------+----------------+
// | Field              | Type             | Null | Key | Default | Extra          |
// +--------------------+------------------+------+-----+---------+----------------+
// | id                 | int(11)          | NO   | PRI | NULL    | auto_increment |
// | title              | varchar(255)     | NO   |     |         |                |
// | slug               | varchar(255)     | YES  |     |         |                |
// | first_category_id  | int(11) unsigned | YES  | MUL | 0       |                |
// | second_category_id | int(11) unsigned | YES  |     | 0       |                |
// | pc_cover_id        | int(11) unsigned | YES  |     | 0       |                |
// | wap_cover_id       | int(11) unsigned | YES  |     | 0       |                |
// | description        | varchar(255)     | NO   |     |         |                |
// | content            | text             | YES  |     | NULL    |                |
// | seo_description    | varchar(255)     | YES  |     |         |                |
// | seo_keywords       | varchar(255)     | YES  |     |         |                |
// | view_count         | int(11) unsigned | YES  |     | 0       |                |
// | status             | tinyint(1)       | YES  |     | 1       |                |
// | sort               | int(11)          | YES  |     | 0       |                |
// | is_recommand       | tinyint(1)       | YES  |     | 0       |                |
// | member_id          | int(11) unsigned | YES  |     | 0       |                |
// | create_time        | int(11) unsigned | YES  |     | 0       |                |
// | update_time        | int(11) unsigned | YES  |     | 0       |                |
// | delete_time        | int(11) unsigned | YES  |     | 0       |                |
// | host               | varchar(255)     | YES  |     |         |                |
// | address            | varchar(255)     | YES  |     |         |                |
// | unit_price         | varchar(50)      | YES  |     |         |                |
// | attachment_path    | varchar(255)     | YES  |     |         |                |
// | start_time         | int(11) unsigned | YES  |     | 0       |                |
// | end_time           | int(11) unsigned | YES  |     | 0       |                |
// +--------------------+------------------+------+-----+---------+----------------+
namespace app\common\validate;

use think\Validate;

class Article extends Validate
{
    protected $rule = [
        "title" => "require|min:3|max:50",
        "content" => "require",
        "seo_description" => "max:200",
        "seo_keywords" => "max:200",
        "first_category_id" => "gt:0",
        "second_category_id" => "gt:0",
        "pc_cover_id" => "gt:0",
        "wap_cover_id" => "egt:0",
        "member_id" => "egt:0",
    ];

    protected $field = [
        "title" => "标题",
        "slug" => "标题链接名",
        "content" => "正文",
        "description" => "摘要",
        "seo_description" => "SEO描述",
        "seo_keywords" => "SEO关键词",
        "host" => "主办单位",
        "address" => "活动地址",
        "unit_price" => "报名费用",
        "start_time" => "报名开始时间",
        "end_time" => "报名结束时间",
        "first_category_id" => "所属栏目",
        "second_category_id" => "所属分类",
        "pc_cover_id" => "封面图片",
        "wap_cover_id" => "手机版封面图片",
        "member_id" => "编辑管理员",
    ];

    protected $message = [
        "title.require" => "标题不能为空",
        "title.min" => "标题长度必须在3-50个字符之间",
        "title.max" => "标题长度必须在3-50个字符之间",
        "slug" => "标题链接名长度不能超过200个字符",
        "content.require" => "正文不能为空",
        "content.min" => "正文信息不能少于10个字符",
        "description" => "摘要不能为空",
        "description.min" => "摘要长度不能少于10个字符",
        "description.max" => "摘要长度不能超过200个字符",
        "seo_description.max" => "SEO描述长度不能超过200个字符",
        "seo_keywords.max" => "SEO关键词长度不能超过200个字符",
        "host.require" => "主办单位不能为空",
        "host.max" => "主办单位长度不能超过20个字符",
        "address.require" => "活动地址不能为空",
        "address.max" => "活动地址不能超过50个字符",
        "unit_price.require" => "报名费用不能为空",
        "unit_price.max" => "报名费用长度不能超过20个字符",
        "start_time.require" => "报名开始时间不能为空",
        "start_time.gt" => "报名开始时间不能为空",
        "end_time.require" => "报名结束时间不能为空",
        "end_time.gt" => "报名结束时间不能为空",
        "first_category_id.gt" => "所属栏目不正确",
        "second_category_id.gt" => "所属分类不能为空",
        "pc_cover_id.gt" => "封面图片不能为空",
        "wap_cover_id.egt" => "手机版封面图片不能为空",
        "member_id.egt" => "编辑管理员不正确",
    ];

    protected $scene = [
        'default'  =>  ['title','slug', 'content', 'seo_description', 'seo_keywords', 'first_category_id', 'second_category_id', 'member_id'],
    ];
}